//
//  RecommandCollectionCell.swift
//  appstore
//
//  Created by llbt-sk on 2019/11/7.
//  Copyright © 2019 Roy. All rights reserved.
//

import UIKit

class RecommandCollectionCell: UICollectionViewCell {
    
    var featureLabel: UILabel!
    var nameLabel: UILabel!
    var descLabel: UILabel!
    var coverImageView: UIImageView!
    
    var model:GameRecommandModel! {
        didSet {
            featureLabel.text = model.feature
            nameLabel.text = model.name
            descLabel.text = model.desc
            coverImageView.image = UIImage(named: model.coverImageName)
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.initView()
    }
    
    func initView() -> Void {
        
        featureLabel = UILabel()
        featureLabel.font = UIFont.systemFont(ofSize: 15.0)
        featureLabel.textColor = .blue
        self.contentView.addSubview(featureLabel)
        featureLabel.snp.makeConstraints { (make) in
            make.top.equalTo(12.0)
            make.left.right.equalTo(0.0)
            make.height.equalTo(15.0)
        }
        
        nameLabel = UILabel()
        nameLabel.font = UIFont.systemFont(ofSize: 20.0)
        self.contentView.addSubview(nameLabel)
        nameLabel.snp.makeConstraints { (make) in
            make.top.equalTo(featureLabel.snp.bottom).offset(5.0)
            make.left.right.equalTo(0.0)
            make.height.equalTo(25.0)
        }
        
        descLabel = UILabel()
        descLabel.font = UIFont.systemFont(ofSize: 20.0)
        descLabel.textColor = .gray
        self.contentView.addSubview(descLabel)
        descLabel.snp.makeConstraints { (make) in
            make.top.equalTo(nameLabel.snp.bottom).offset(5.0)
            make.left.right.equalTo(0.0)
            make.height.equalTo(25.0)
        }
        
        coverImageView = UIImageView()
        coverImageView.layer.cornerRadius = 10.0
        coverImageView.layer.masksToBounds = true
        self.contentView.addSubview(coverImageView)
        coverImageView.snp.makeConstraints { (make) in
            make.top.equalTo(descLabel.snp.bottom).offset(5.0)
            make.left.right.equalTo(0.0)
            make.bottom.equalTo(-10.0)
        }
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
